import axios from "axios";
// eslint-disable-next-line
export default {
  //获取商品大类数据
  get: () => axios.get("/api/navs").then(({ data }) => data),
  //新增商品大类
  addNav: ({ name }) =>
    axios
      .post("/api/navs", {
        name,
      })
      .then(({ data }) => data),
  //删除商品大类
  delNav: (_id) =>
    axios.delete("/api/navs/del", { data: { _id } }).then(({ data }) => data),
  //通过id获取某一条商品大类数据
  getOne: (_id) =>
    axios
      .get(`/api/navs/${_id}`, { params: { _id } })
      .then((response) => response.data),
  //通过id修改某一条商品大类数据
  changeOne: ({ _id, name }) =>
    axios
      .put(`/api/navs/change`, {
        _id,
        name,
      })
      .then((response) => response.data),
};
